package xin.javashare.javacollectionsframework.mycollectionsframework;

public class TestMyArrayList {
    public static void main(String[] args) {
        // Create a list
        Mylist<String> list = new MyArrayList<>();

        // Add elements to the list
        list.add("America");
        System.out.println("(1) " + list);

        list.add(0, "Canada"); // Add it to the list at index 0
        System.out.println("(2) " + list);

        list.add("Russia");
        System.out.println("(3) " + list);

        list.add("France");
        System.out.println("(4) " + list);

        list.add(2, "Germany"); // Add it to the list at index 2
        System.out.println("(5) " + list);

        list.add(5, "Norway"); // Add it to the list at index 5
        System.out.println("(6) " + list);

        // Remove elements from the list
        list.remove("Canada");
        System.out.println("(7) " + list);

        list.remove(2); // Remove the element at index 2
        System.out.println("(8) " + list);

        list.remove(list.size() - 1); // Remove the last element
        System.out.println("(9) " + list);

        System.out.println("get():" + list.get(2));

        System.out.println("set():" + list.set(2, "sss"));
        System.out.println(list);
    }
}
